﻿
# load an assembly from the samples bin directory
Add-Type -Path "bin\Eswat.Samples.SampleComponentLibrary.dll"

# alias test services
$web = $EswatTest.Services.Get('WebDriver')
$verify = $EswatTest.Services.Get('Verify')

# test a sample .NET component
$comp = New-Object Eswat.Samples.SampleComponentLibrary.SampleComponent
$comp.Title = "hello component world!"
$verify.AreEqual("hello component world!", $comp.Title, "sample component title should match")

# -------------------------------------------------------------
# test WebDriver test service
# -------------------------------------------------------------

$web.Open([Eswat.Services.WebDriver.WebBrowserType]::IE)

$nav = $web.Navigate()

$nav.GoToUrl('http://localhost:61614/Auth/SignOut')

$verify.AreEqual('Mileage Stats | Know where your gas takes you', $web.Title, 'Silk landing page title should match')

$web.Quit()

# -------------------------------------------------------------
# test NUnit test service
# -------------------------------------------------------------

$verify.True($true)
$verify.True($true, 'True($true) should succeed')
$verify.True($true, 'True({0}) should succeed', 'True')
$verify.True($false, 'True($false) should fail')

$verify.IsTrue($true)
$verify.IsTrue($true, 'IsTrue($true) should succeed')
$verify.IsTrue($true, 'IsTrue({0}) should succeed', 'True')
$verify.IsTrue($false, 'IsTrue($false) should fail')

$verify.False($false)
$verify.False($false, 'False($false) should succeed')
$verify.False($false, 'False({0}) should succeed', '$false')
$verify.False($true, 'False($true) should fail')

$verify.IsFalse($false)
$verify.IsFalse($false, 'IsFalse($false) should succeed')
$verify.IsFalse($false, 'IsFalse({0}) should succeed', '$false')
$verify.IsFalse($true, 'IsFalse($true) should fail')

# bool
$verify.AreEqual($true, $true)
$verify.AreEqual($true, $true, 'AreEqual($true, $true) should succeed')
$verify.AreEqual($true, $true, 'AreEqual({0}) should succeed', '$true, $true')
$verify.AreEqual($true, $false, 'AreEqual($true, $false) should fail')

# float
$verify.AreEqual([float]0.0, [float]0.0)
$verify.AreEqual([float]0.0, [float]0.0, 'AreEqual([float]0.0, [float]0.0) should succeed')
$verify.AreEqual([float]0.0, [float]0.0, 'AreEqual({0}) should succeed', '[float]0.0, [float]0.0')
$verify.AreEqual([float]0.0, [float]0.1, 'AreEqual([float]0.0, [float]0.1) should fail')

# double -> passed to .NET as Double
$verify.AreEqual(0.0, 0.0)
$verify.AreEqual(0.0, 0.0, 'AreEqual(0.0, 0.0) should succeed')
$verify.AreEqual(0.0, 0.0, 'AreEqual({0}) should succeed', '0.0, 0.0')
$verify.AreEqual(0.0, 0.1, 'AreEqual(0.0, 0.1) should fail')

# decimal
$verify.AreEqual([decimal]0.0, [decimal]0.0)
$verify.AreEqual([decimal]0.0, [decimal]0.0, 'AreEqual([decimal]0.0, [decimal]0.0) should succeed')
$verify.AreEqual([decimal]0.0, [decimal]0.0, 'AreEqual({0}) should succeed', '[decimal]0.0, [decimal]0.0')
$verify.AreEqual([decimal]0.0, [decimal]0.1, 'AreEqual([decimal]0.0, [decimal]0.1) should fail')